// 定义一个用户的reducer
const defaultUserState = {
    userinfo: {
        name: '张会娟',
        age: 33
    },
    schoollist: []
}
const userReducer = (state = defaultUserState, actions) => {
    // 修改年龄
    if (actions.type == 'addage') {
        return {
            ...state,
            userinfo: {
                ...state.userinfo,
                age: state.userinfo.age + actions.payload
            }
        }
    }

    // 修改学校列表
    if (actions.type == 'setlist') {
        return {
            ...state,
            schoollist: actions.payload
        }
    }

    return state
}


export default userReducer